<?php
/**
 *+------------------
 * Lflow
 *+------------------
 * Copyright (c) 2023~2030 gitee.com/liu_guan_qing All rights reserved.本版权不可删除，侵权必究
 *+------------------
 * Author: Mr.April(405784684@qq.com)
 *+------------------
 */
declare (strict_types=1);

namespace lflow;

use lflow\entity\Order;
use lflow\entity\Process;

/**
 * 流程实体业务类
 * @author Mr.April
 * @since  1.0
 */
interface IOrderService
{
    /**
     * createOrder
     *
     * @param \lflow\entity\Process $process
     * @param string                $operator
     * @param string                $args
     * @param string                $parentId
     * @param string                $parentNodeName
     * @param int                   $priority
     *
     * @return \lflow\entity\Order
     */
    public function createOrder(Process $process, string $operator, string $args, string $parentId = '', string $parentNodeName = '', int $priority = 1): Order;

    /**
     * addVariable  向指定实例id添加全局变量数据
     *
     * @param String $orderId 实例id
     * @param string $args    变量数据
     */
    public function addVariable(string $orderId, string $args): void;

    /**
     * createCCOrder
     *
     * @param String $orderId  流程实例id
     * @param String $creator  创建人id
     * @param String $actorIds 参与者id
     */
    public function createCCOrder(string $orderId, string $creator, string $actorIds): void;

    /**
     * complete  流程实例正常完成
     *
     * @param String $orderId 流程实例id
     */
    public function complete(string $orderId): void;

    /**
     * saveOrder  保存流程实例
     *
     * @param \lflow\entity\Order $order
     */
    public function saveOrder(Order $order): void;

    /**
     * terminate  流程实例强制终止
     *
     * @param String $orderId 流程实例id
     */
    public function terminate(string $orderId, string $operator): void;

    /**
     * resume  唤醒历史流程实例
     *
     * @param String $orderId 流程实例id
     *
     * @return \lflow\entity\Order
     */
    public function resume(string $orderId): Order;

    /**
     * updateOrder  更新流程实例
     *
     * @param \lflow\entity\Order $order
     *
     * @return mixed
     */
    public function updateOrder(Order $order): void;

    /**
     * updateCCStatus  更新抄送记录为已阅
     *
     * @param String $orderId  流程实例id
     * @param String $actorIds 参与者id
     */
    public function updateCCStatus(string $orderId, string $actorIds): void;

    /**
     * deleteCCOrder  删除抄送记录
     *
     * @param String $orderId 流程实例id
     * @param String $actorId 参与者id
     */
    public function deleteCCOrder(string $orderId, string $actorId): void;

    /**
     * cascadeRemove  谨慎使用.删除删除无法恢复~~
     * 级联删除指定流程实例的所有数据：
     * 1.wf_order,wf_hist_order
     * 2.wf_task,wf_hist_task
     * 3.wf_task_actor,wf_hist_task_actor
     * 4.wf_cc_order
     * Date  2023/3/29 11:27
     *
     * @param string $id
     */
    public function cascadeRemove(string $id): void;

}